package com.example.leetcode.trainingcamp.week12;

import java.util.HashMap;
import java.util.Map;
import java.util.Objects;

public class Offer56_II {


    public int singleNumber(int[] nums) {
        Map<Integer,Integer> map = new HashMap<>();
        for (int i:nums){
            map.put(i,map.getOrDefault(i,0)+1);
        }
        for (Map.Entry<Integer,Integer> entry:map.entrySet()) {
            Integer value = entry.getValue();
            if (Objects.equals(value,1)){
                return entry.getKey();
            }
        }
        return -1;
    }
}
